Modern processors are typically capable of performing processing operations in high and low precision. The precision determines the number of bits which can be used to represent the fractional part of floating point numbers. The terms “high” and “low” here are simply used to distinguish two different levels of precision (and hence numbers of “fractional bits”), one being higher than the other, and do not imply any particular constraints on the individual precision levels. Hence, the actual numbers of fractional bits used in low and high precision can vary substantially from system to system. For example, the current IEEE standard specifies 32 bits, equivalent to 8 decimal digits after the decimal point, for low-precision (also called “single-precision”) processing, and 64 bits, equivalent to 16 decimal digits after the decimal point, for high-precision (or “double-precision”) processing. Many embedded systems use different specifications, however, for instance 8 and 16 bits, or 10 and 20 bits.
Depending on the type of processor, low-precision and high-precision operations may be implemented by dedicated processing logic or by appropriate software-control of the same processor hardware. Either way, low-precision operation is less complex and significantly faster than high-precision operation. Where complex tasks require high-precision results, a “mixed-precision” approach may therefore be employed. With mixed-precision processing, some components of a task are performed in low-precision, and other components in high-precision, with the overall result being obtained in high-precision. An example of such a processing task which is fundamental to numerous science and engineering applications is the solution of a linear system of equations. This task requires the processor to generate n high-precision data elements corresponding to the elements of a vector x, of dimensions nx1, such thatAx=b where A is a symmetric, positive-definite matrix of dimensions nxn, and b is a vector of dimensions nx1. Matrix A is defined by nxn high-precision data elements which must be stored in memory and accessed when required for the processing operation. Right hand vector b is similarly defined by n high-precision data elements stored in system memory. When the matrix A is dense, the task of generating the high-precision data elements corresponding to solution vector x is highly processor intensive. In particular, when all elements of the coefficient matrix A are non-zero, the task requires a number of arithmetic operations in the processor that grows cubically with the dimension n of matrix A.
Thus far, mixed-precision approaches to the above task have been based on matrix decompositions (transformations). The basic steps of the processing operation are as follows. First, the matrix A must be constructed from nxn high-precision data elements and stored in system memory. The matrix A is then demoted (rounded) to produce a low-precision copy Al in system memory. This is done by converting the high-precision data elements of matrix A to respective low-precision data elements by an appropriate rounding process. Next, the processor implements a decomposition process whereby the matrix Al is decomposed as follows:Al=LLT where L is a lower triangular matrix and LT denotes its transpose. The transformation is performed by means of the Cholesky decomposition. This technique is well known in the art and need not be discussed in detail here. What is important to note is that, while the decomposition can be implemented by low-precision hardware, the cost of this decomposition grows as the cube of the dimension n. The subsequent processing to generate the data elements of a vector solution for a linear system with coefficient matrices L and LT then requires a cost that grows quadratically with the matrix dimension n. This is done using a method of iterative refinement as follows.
An initial, low-precision approximate solution vector xl for Ax=b is obtained by solving L(LTxl)=bl where bl is an nx1 vector with elements corresponding to the nx1 data elements of vector b in low precision. The low-precision data elements of vector xl are promoted to respective high-precision data elements by an appropriate conversion process to obtain a current solution vector x. This can be done in various ways, e.g. by selecting the closest high-precision value in each case. Then, n high-precision data elements are generated corresponding to a current nx1 residual (error) vector r such thatr=b−Ax 
The processor then implements an iterative process until convergence:
1) generate n low-precision data elements corresponding to an nx1 vector z in the linear system L(LTz)=rl where rl corresponds to the current error vector r converted to low precision;
2) convert the data elements of vector z to high-precision elements to obtain the high-precision vector zh;
3) update the data elements of the current, high-precision solution vector x such that x=x+zh; 
4) update the data elements of the current, high-precision error vector r such that r=b−Ax;
5) repeat steps 1 to 4 until convergence is detected (typically when r is small enough or no progress is being made).
In the above process, the Cholesky decomposition requires the matrix A to be formed in memory at the outset. This matrix is then retrieved from memory by the processor each time the high-precision error vector r is calculated in the subsequent operation. In typical applications, the matrix A can be very large, for example of dimension n=10,000 or even much greater, resulting in considerable traffic between the processor and memory subsystem. The matrix transformation process is difficult to implement in a parallel-processing environment due to the level of processor coordination required, and existing techniques do not scale well. In addition as noted above, the overall complexity remains cubic with respect to the dimension n of matrix A. These and other issues limit overall processing efficiency and can restrict the type of hardware able to cope with the processing demands of many applications. Indeed, the cubic complexity alone limits the size of problems that can be handled by current single- and parallel-processor based computing systems.
One aspect of the present invention provides apparatus for generating n high-precision data elements corresponding to an nx1 vector x satisfying Ax=b where A is a symmetric, positive-definite nxn matrix corresponding to nxn predefined high-precision data elements and b is an nx1 vector corresponding to n predefined high-precision data elements. The apparatus comprises memory for storing input data defining said data elements of matrix A and of vector b, and control logic adapted to:
(a) implement a first iterative process for generating from said input data n low-precision data elements corresponding to an nx1 vector xl satisfying Alxl=bl, where A, is an nxn matrix corresponding to the nxn data elements of matrix A in low precision and bl is an nx1 vector corresponding to the nx1 data elements of vector b in low precision, the control logic terminating the first iterative process on occurrence of a first convergence condition;
(b) convert the data elements of vector xl to high-precision data elements to obtain a current solution vector x;
(c) implement a second iterative process for generating n low-precision data elements corresponding to an nx1 correction vector dependent on the difference between the vector b and the vector product Ax, the control logic terminating the second iterative process on occurrence of a second convergence condition;
(d) produce from the n low-precision data elements of said correction vector respective high-precision data elements of an nx1 update vector u;
(e) update the data elements of said current solution vector x such that x=x+u; and
(f) perform steps (c) to (e) until occurrence of a third convergence condition.
Instead of the Cholesky decomposition-based technique of the prior approach, embodiments of this invention implement an iterative process for generating the low-precision data elements of the solution vector xl in step (a), and also implement an iterative process for generating the low-precision data elements of the correction vector (step (c)) which is used to update the current high-precision solution vector x. No matrix transformation is required in this process, but advantage can still be taken of the accelerated performance of low-precision processing. Each iterative refinement step incurs a quadratic cost with respect to matrix size n, so the overall cost of the processing operation grows in the worst case only quadratically with matrix size n as compared with the cubic cost of the prior system. Moreover, the entire processing operation can be implemented using only the matrix vector product of matrix A with another vector (xl in step (a) and the correction vector in step (c)). This avoids the parallel-processing problem associated with the transformation-based process discussed above. Indeed, operations based on matrix vector products are particularly amenable to parallel implementation, whereby embodiments of the invention can be realized in massively-parallel implementations. In addition to this, the formation of matrix A is not a prerequisite for operation of the processing apparatus. As explained above, in the prior technique the matrix A must first be constructed in memory and is then retrieved from memory in each iteration for generating the error vector r. In contrast, the vector products required in embodiments of this invention can be generated without ever forming matrix A. In particular, it is common practice to define the matrix A as a certain function, whereby the computation of a matrix vector product with A is simple and computationally cheap. This will be described further below, but the effect is to substantially simplify processing and dramatically reduce traffic to the memory subsystem since loading of a preformed matrix from memory can be avoided in every iteration.
Further enhancements in operating efficiency stem from the use of iterative processes in steps (a) and (c). In the prior system, the solution of a linear system based on the decomposition LLT is obtained to a specific accuracy in each pass of the iterative process. For example, solution of L(LTz)=rl for z involves a fixed number of steps and yields a vector z of a defined precision, i.e. having data elements corresponding to values calculated to the number of bits available for the low-precision process. This imposes a much more strict accuracy requirement than the theoretical properties of iterative refinement require. Each of the iterative processes of steps (a) and (c) above is terminated by the control logic on occurrence of a predetermined convergence condition, and this allows embodiments of the invention to adapt automatically to the required accuracy. A convergence condition is typically defined as the completion of a predetermined maximum number of iterations or convergence of the solution (achieving a solution according to a predetermined tolerance, or detecting no progress between iterations). Thus, not only are the iterative processes able to exploit fast, low precision logic, these processes terminate immediately a solution of the required accuracy is achieved. This is not possible with the standard matrix-factorization based system.
While the control logic might be adapted to perform steps (c) and (d) in various ways, these steps are preferably based on an error vector r which his dependent on the difference between the vector b and the vector product Ax, and in particular on the iterative generation of a correction vector whose matrix vector product with A depends on the error vector r. Hence, in preferred embodiments the control logic is adapted:
after generating the current solution vector x in step (b), to generate n data elements corresponding to a current nx1 error vector r indicative of the difference between the vector b and the vector product Ax;
to perform step (c) such that the vector product of the matrix A, with said correction vector is dependent on the error vector r; and
in step (d), to produce the data elements of the update vector u by converting the data elements of the correction vector to high-precision data elements.
The data elements of the error vector r are preferably generated by the control logic in high precision such that r=b−Ax, and then converted to respective low precision data elements to obtain a low-precision error vector rl. This can then be used in the second iterative process of step (c) such that the vector product of the matrix A, with the correction vector is equal to the low-precision error vector rl. Then, in step (e), after updating the data elements of the current solution vector x, the control logic can update the data elements of the current error vector r such that r=b−Ax. In such embodiments, the third convergence condition is conveniently dependent on the current error vector r.
While alternatives can be envisaged, in preferred embodiments each of the first and second iterative processes comprises the well-known Conjugate Gradient method. In general, the various convergence conditions can be set as desired for a given application, but these conditions are preferably dependent on completion of a predetermined number of passes of the iterative process in question and/or detected convergence of the resulting solution (attainment of a solution vector to a predetermined tolerance or no detected progress between successive passes of the process).
The predefined data elements of matrix A and vector b could be individually predetermined in system memory or may be defined by the input data in any convenient manner. For example, as mentioned earlier, the input data defining the data elements of matrix A may comprise a function F defining application of matrix A on an arbitrary nx1 vector. That is, the function F defines application of each matrix A element a(i,j) on an element of any nx1 vector, where 1≦i≦n and 1≦j≦n are the row and column indices respectively of matrix A elements. In this case, the control logic is adapted to use the function F in performance of steps (a) to (e) for exceptionally fast and computationally inexpensive generation of matrix-vector products with A. In particular, processing operations involving matrix element a(i,j) can typically be done wholly in processor cache, and the memory traffic resulting from generation of a matrix vector product with A can be dramatically reduced over prior systems. This will be discussed further below.
Apparatus embodying the invention might be implemented by one or more processors using shared and/or individually-assigned memory resources. For most efficient operation, and especially in complex applications, the control logic ideally comprises a plurality of processors arranged to operate in parallel collectively to implement steps (a) to (e). In general, the processor(s) could use dedicated low- and high-precision hardware or use common hardware configurable by software for low- and high-precision operation. Where a plurality of processors are employed, these may be integrated in a single chip or dispersed over different chips of a uniprocessor and/or multicore processor based computing system, e.g. over multiple computers of a distributed computing system. Similarly, the memory utilised in operation of apparatus embodying the invention may comprise one or more components of one or more types of storage, from local processor cache memory to main storage such as disk or back-up storage media, and such memory or components thereof may be wholly or partly shared by different processors of the control logic.
A second aspect of the invention provides a computer program for causing a computer to generate n high-precision data elements corresponding to an nx1 vector x satisfying Ax=b where A is a symmetric, positive-definite nxn matrix corresponding to nxn predefined high-precision data elements and b is an nx1 vector corresponding to n predefined high-precision data elements. The computer program comprises program code means for causing the computer to access input data, stored in memory of the computer and defining said data elements of matrix A and of vector b, and to:
(a) implement a first iterative process for generating from said input data n low-precision data elements corresponding to an nx1 vector xl satisfying Alxl=bl, where A, is an nxn matrix corresponding to the nxn data elements of matrix A in low precision and bl is an nx1 vector corresponding to the nx1 data elements of vector b in low precision, and terminate the first iterative process on occurrence of a first convergence condition;
(b) convert the data elements of vector xl to high-precision data elements to obtain a current solution vector x;
(c) implement a second iterative process for generating n low-precision data elements corresponding to an nx1 correction vector dependent on the difference between the vector b and the vector product Ax, and terminate the second iterative process on occurrence of a second convergence condition;
(d) produce from the n low-precision data elements of said correction vector respective high-precision data elements of an nx1 update vector u;
(e) update the data elements of said current solution vector x such that x=x+u; and
(f) perform steps (c) to (e) until occurrence of a third convergence condition.
It will be understood that the term “computer” is used in the most general sense and includes any device, component or system having a data processing capability for implementing a computer program, and may thus comprise one or more processors of a single device or distributed system of devices as discussed above. Moreover, a computer program embodying the invention may constitute an independent program or program set, or may be part of a larger program or program set, and may be supplied, for example, embodied in a computer-readable medium such as a disk or an electronic transmission for loading in a computer. The program code means of the computer program may comprise any expression, in any language, code or notation, of a set of instructions intended to cause a computer to perform the method in question, either directly or after either or both of (a) conversion to another language, code or notation, and (b) reproduction in a different material form.
In general, where features are described herein with reference to an embodiment of one aspect of the invention, corresponding features may be provided in embodiments of another aspect of the invention.
FIG. 1 is a simplified schematic of processing apparatus embodying the invention indicating the main components involved in the operation to be described. The apparatus 1 comprises control logic, represented in the figure by controller 2, and memory 3 represented in simplified form here by cache memory 4 and main memory 5. The control logic of controller 2 comprises both high- and low-precision logic whereby controller 2 can perform processing operations in high and low precision. In general, the control logic of controller 2 may be implemented in hardware or software or a combination thereof. In this embodiment, however, the logic is implemented by one or more processor cores which are configured by software to perform the functions described. Suitable software will be apparent to those skilled in the art from the description herein. While in general the high- and low precision operations to be described might be performed by different processors of apparatus 1, in the present example we assume that the processor(s) of controller 1 are individually operable under software control to perform operations in high or low precision. Cache memory 4 here represents the main working memory of controller 2, e.g. level 1 cache memory. Main memory 5 represents the remainder of the memory subsystem accessible by controller 2 and may include various types of storage such as additional cache levels, hard disk and backup storage media.
The apparatus 1 is adapted to implement a process for generating n high-precision data elements corresponding to an nx1 vector x representing the solution of a linear system of equations defined byAx=b. 
Here, A is a symmetric, positive-definite, dense matrix of dimensions nxn and b is an nx1 vector. The nxn high-precision data elements corresponding to the elements of matrix A and the n high-precision data elements corresponding to the elements of vector b are defined by input data stored in memory 5. More specifically, the high-precision data elements of matrix A are defined indirectly here via a scalar function F( )=a(i,j), where a(i,j) represents an element with row index i (1≦i≦n) and column index j (1≦j≦n). In this example we assume that the data elements of vector b are directly defined in memory 5. Memory 5 also holds data C1(k1, d1), C2(k2, d2), and C3(p, c) specifying the parameters defining three convergence conditions for use in the processing operation. These parameters will be explained in the following.
The key steps performed by apparatus 1 to generate the high-precision data elements of solution vector x are indicated in the flow chart of FIG. 2. Operation commences at step 10, typically in response to an operator prompt via an I/O (input/output) interface (not shown) of the apparatus or a request from another application, whether running on a processor of controller 2 or a remote processor in communication with controller 2. In step 11, controller 2 accesses main memory 1 to retrieve the high-precision function F( ) and creates a low-precision copy Fl( ) in cache memory 4. This can be done in known manner by demoting, or rounding, the high-precision function to a low-precision representation. Similarly, controller 1 retrieves the high-precision data elements of vector b and demotes these to respective low-precision elements to produce a low-precision vector bl. Depending on storage capacity and the dimension n, the data elements of vector bl may be retained in cache 4 or re-stored in main memory 5.
Next, in step 12 controller 1 performs one pass of a first iterative process for generating n low-precision data elements corresponding to an initial, approximate nx1 solution vector xl satisfyingAlxl=bl.
Here, Al is the nxn low-precision matrix defined by the function Fl( ). In this embodiment, the technique employed for the first iterative process is the conjugate gradient (CG) process. The CG process is a well known technique for the solution of linear systems of equations, and need not be described further here. The necessary calculations can be performed by controller 2 using only the function Fl( ) and the elements of vector bl which can be recalled from main memory 5 to cache 4 as required. The low-precision elements of vector xl obtained after one pass of the CG process are stored in memory 3, and operation proceeds to step 13 where a pass counter px is incremented by one by controller 2. In decision step 14, controller 2 checks if the current pass count px is equal to the preset parameter k1 which indicates the maximum number of permitted passes of the first iterative process. Assuming not (decision “No” (N) at step 14), controller 2 then decides at decision step 15 if convergence of the solution xl has occurred. Convergence here is detected if either of two events has occurred. The first event is that a preset drop tolerance d1 for xl has been reached. That is, controller 2 checks whether the current solution for xl differs from that obtained in the first pass by an amount ≧d1, where the drop tolerance d1 is typically specified as a percentage change. The second event is that no progress has been achieved in this pass of the process, i.e. that the solution for xl is unchanged from that obtained in the preceding pass. Assuming convergence is not detected at step 15, operation reverts to step 12 for another pass of the solution process. The process thus iterates until occurrence of a first convergence condition C1 defined as the first-occurring of k1 passes being completed at step 14 or convergence being identified at step 15. On detection of the convergence condition C1 (decision “Yes” (Y) at step 14 or step 15), the controller 2 terminates the first iterative process.
On completion of the first iterative process, operation proceeds to step 16 where the controller 2 creates a high-precision copy of the solution vector xl output by the first iterative process. This can be done in known manner by converting the low-precision data elements of vector xl to respective high-precision data elements to obtain a current, high-precision solution vector x which is stored in memory 3. Next, in step 17 controller 2 generates n high-precision data elements corresponding to a current nx1 error vector r satisfyingr=b−Ax. 
This calculation can be performed using the function F( ) and the elements of vectors x and b which can be recalled to cache 4 as required. The resulting high-precision elements of error vector r are stored in memory 3 together with a low-precision copy rl of this error vector which is generated in step 18 by converting the elements of vector r to respective low-precision data elements.
In step 19, controller 2 then performs the first pass of a second iterative process for generating n low-precision data elements corresponding to an nx1 correction vector z satisfyingAlz=rl.
Again, the conjugate gradient technique is used for the second iterative process in this example, and the necessary calculations can be performed by controller 2 using the function Fl( ). The low-precision elements of vector z obtained after one pass of the process are stored in memory 3, and operation proceeds to step 20 where a pass counter pz is incremented by one by controller 2. In decision step 21, controller 2 checks if the current pass count pz is equal to the preset parameter k2 which indicates the maximum number of permitted passes of the second iterative process. If not, controller 2 determines at decision step 22 if convergence of the solution z has occurred. Convergence here is again detected if either (1) a preset drop tolerance d2 for z has been reached or (2) no progress has been achieved in this pass of the process, i.e. that the solution for z is unchanged since the preceding pass. Assuming convergence is not detected at step 22, operation reverts to step 19 for another pass of the solution process. The process thus iterates until occurrence of second convergence condition C2 defined as the first-occurring of k2 passes being completed at step 21 or convergence being identified at step 22. On detection of the convergence condition C2 (Y at step 21 or step 22), the controller 2 terminates the second iterative process.
On completion of the second iterative process, operation proceeds to step 24 where the controller 2 converts the data elements of the correction vector z to respective high-precision data elements to produce a high-precision update vector u which is stored in memory 3. Next, in step 25 the controller 2 updates the data elements of the current high-precision solution vector x such thatx=x+u and stores the updated solution x in memory 3. After updating the solution vector x, controller 2 updates current high-precision error vector r in step 26 such that:r=b−Ax, where again the calculation is performed using function F( ) defining matrix A. The high-precision elements of the new vector r are stored in memory 3, and operation proceeds to step 27 where a pass counter pr for a third iterative process is incremented by one by controller 2. In decision step 28, controller 2 checks if the current pass count pr is equal to the preset parameter p which indicates the maximum number of permitted passes of the third iterative process. If not, controller 2 determines at decision step 29 if convergence of the solution r has occurred. As before, convergence is detected if either (1) a preset tolerance c for r has been reached or (2) no progress has been achieved in the solution for r since the preceding pass of the process. In this case, the tolerance c specifies an error threshold, whereby an error vector r whose Euclidean norm is less than c is deemed within the required tolerance. Assuming convergence is not detected at step 29, operation reverts to step 18 for another pass of the third iterative process, requiring performance of the second iterative process again for the new error vector r. The process of steps 18 to 29 thus iterates until occurrence of a third convergence condition C3 defined as the first-occurring of p passes being completed at step 28 or convergence of the solution for the error vector r being identified at step 29. On detection of the convergence condition C3 (Y at step 28 or step 29), the controller 2 terminates the third iterative process. In step 30, the high-precision data elements corresponding to the final solution vector x are output to the operator or application which initiated the process, and the processing operation is complete.
The foregoing apparatus offers exceptional operating efficiency for the solution of linear systems of equations, even where the matrix A is dense and the dimension n very large. The apparatus exploits fast, low-precision processing, and the complexity of the processing operation is only O(kn2) for k1=k2=k. This is in marked contrast to the prior system described earlier which incurs a cost of O(n3).
Note that all the calculations involving matrix A or Al in the above process require only the matrix vector product of A or Al with another vector. These calculations do not require prior formation of matrix A, but can be performed by controller 2 using only the function F( ) or Fl( ) as appropriate and the elements of the vector in question which can be recalled as required from main memory 5 to cache 4. That is, the necessary processing operations involving matrix A (or Al) can be performed entirely in processor cache. This dramatically reduces traffic between the processor(s) of controller 2 and the memory subsystem as compared with the prior approach described earlier. In particular, in the embodiment above the calculation of a matrix vector product with A (or Al) requires only O(kn) of memory movements where k is typically small by comparison with dimension n. In contrast, the prior scheme requires matrix A to be formed in system memory prior to decomposition. This matrix is decomposed as A=LLT where L is a lower triangular matrix with O(n/2) elements. The matrix L, which is stored in lower precision, is used in all solution cases. The original matrix A in high precision is used in the calculation of the errors. Thus, in the prior system O(n2) of data needs to be moved from main memory to the processor in each iterative refinement step of that process.
The parameters defining the three convergence conditions C1(k1, d1), C2(k2, d2), and C3(p, c) can be set as desired for according to the accuracy required in a given application. In preferred embodiments, k1=k2=k is selected for convenience of implementation, whereby the maximum number of passes is the same in the first and second iterative processes. Note that, unlike the process of calculating the error in the prior system, these processes need not fully solve towards the error vector r but can adapt automatically to the required accuracy.
As described earlier, apparatus 1 can be realized by a plurality of processors operating in parallel, these processors collectively implementing the processing operation described above. FIG. 3 illustrates a simple example of such an implementation. Here, the functionality of controller 2 is implemented by multiple processors, in this case having individual level one (L1) caches, which communicate via a bus interface (I/F) with a shared memory subsystem. Since the processing operation is based on matrix vector products, the number of processors used can be large. Such massively parallel implementations offer exceptional operating efficiency. FIG. 4 compares run times for embodiments of the invention and prior systems described above for two different values of matrix dimension n and various numbers of parallel processors. The vertical axis corresponds to run time and the horizontal axis corresponds to number of processors employed. The two values of matrix size n are 32768 and 49152. The upper pair of traces, shown in solid lines, corresponds to the prior scheme, and the lower pair of traces, in dashed lines, corresponds to embodiments of this invention. Note that the scale on the vertical axis is logarithmic. It is immediately clear that embodiments of the invention provide a substantial improvement, reducing run times by at least one order of magnitude.
Embodiments of the invention also offer significant memory usage and bandwidth improvements. The table of FIG. 5 indicates the memory usage (required bandwidth) in GBytes for each step of iterative refinement of the error vector r, using the prior scheme and embodiments of the invention as described above, for various sizes of matrix A. The top row in this table gives the results for the prior system with different values of n. The lower four rows give the results for different values of k1=k2=k in the embodiment described. The dramatic improvement achieved by embodiments of the invention is readily apparent.
It will be appreciated that many changes and modifications can be made to the exemplary embodiments described above. By way of example, the convergence conditions for the iterative processes could be dependent on different sets of events to those specified and may depend in various ways on combinations of these events. Preferred embodiments always specify a maximum number of iterations for each process however. Where a tolerance is specified for a convergence condition, this could be defined in various ways as desired for a given application. Also, while the conjugate gradient method is employed in the first and second iterative processes above, other iterative solution techniques for linear systems of equations might be employed here if desired. Many other changes and modifications can be made to the embodiments described without departing from the scope of the invention.